package com.hxd.otc.module.convenience.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.convenience.bean.PaymentMethodBean;
import com.hxd.otc.module.convenience.bean.RateBean;
import com.hxd.otc.module.convenience.contract.HydropwerDetailContract;
import com.hxd.otc.module.convenience.model.ConvenienceModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

import java.util.ArrayList;

/**
 * 作  者 :  zjl
 * 时  间 :  2018/6/4 17:02
 * 描  述 :  ${所有订单页面 Presenter}
 */
public class HydropwerDetailPresenter extends BasePresenter<HydropwerDetailContract.View> implements HydropwerDetailContract.Presenter {

    ConvenienceModel model;
    ArrayList<PaymentMethodBean> beans;

    public HydropwerDetailPresenter(HydropwerDetailContract.View view) {
        super(view);
        model = ConvenienceModel.getInstance();
    }

    @Override
    public void start() {
//        model.getPaymentMethodList(new BaseObserver<ArrayList<PaymentMethodBean>>() {
//            @Override
//            public void onNext(@NonNull String msg, @NonNull ArrayList<PaymentMethodBean> paymentMethodBeans) {
//                beans = paymentMethodBeans;
//                setPaymentMethodList(beans);
//                mView.setPaymentMethodList(beans);
//            }
//
//            @Override
//            public void onError(int errType, @NonNull String errMessage) {
//                mView.showToast(errMessage);
//            }
//        }, mView.<BaseBean<ArrayList<PaymentMethodBean>>>bindAutoDispose());
    }


    @Override
    public ArrayList<PaymentMethodBean> getPaymentMethodList() {
        return beans;
    }

    @Override
    public void setPaymentMethodList(ArrayList<PaymentMethodBean> paymentMethodBeans) {

    }

    @Override
    public void getRate(final String sellPrice, String priceUint, String symbol) {
        model.getRate(sellPrice, priceUint, symbol, new BaseObserver<RateBean>() {
            @Override
            public void onNext(@NonNull String msg, @NonNull RateBean rateBean) {
                mView.setRate(rateBean, sellPrice);
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                mView.showToast(errMessage);
                mView.onError(errType);
            }
        }, mView.<BaseBean<RateBean>>bindAutoDispose());
    }
}
